using System;
using System.Data.SqlClient;
using NUnit.Framework;

namespace WebAPI.Dao;

public class NHibernateHelper
{
    // private ISessionFactory _sessionFactory;
    private string connectString = "server=.;database=ink_note;uid=sa;pwd=123";
    private SqlConnection sqlConnection;
    public NHibernateHelper()
    {
        sqlConnection = new SqlConnection(connectString);
        // _sessionFactory = GetSessionFactory();
    }
    // private ISessionFactory GetSessionFactory()
    // {
    //     return (new Configuration()).Configure().BuildSessionFactory();
    // }
    // public ISession GetSession()
    // {
    //     // return _sessionFactory.OpenSession();
    // }

    [Test]
    public static void Main()
    {
        SqlConnection connection = new NHibernateHelper().sqlConnection;
        connection.Open();
        Console.WriteLine(connection);
        Console.WriteLine(connection.State);
        SqlCommand sqlCommand = new SqlCommand("select count(*) from ink_note.[user] where username='123';", connection);
        int executeScalar = (int)sqlCommand.ExecuteScalar();
        Console.WriteLine(executeScalar);
        connection.Close();
        // Console.Write(new NHibernateHelper().GetSession().Statistics);
    }
    
}
